package cn.itcast.bos.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.transaction.annotation.Transactional;

import org.springframework.stereotype.Service;

import cn.itcast.bos.dao.IRoleDao;
import cn.itcast.bos.domain.Function;
import cn.itcast.bos.domain.Role;
import cn.itcast.bos.service.IRoleService;
@Service
@Transactional
public class RoleServiceImpl implements IRoleService{
	@Resource
	private IRoleDao roleDao;

	public void save(Role role, String functionIds) {
		roleDao.save(role);//持久状态对象
		String[] ids = functionIds.split(",");
		for (String id : ids) {
			//角色关联权限对象
			Function function = new Function();
			function.setId(id);
			role.getFunctions().add(function);
		}
	}

	public List<Role> findAll() {
		return roleDao.findAll();
	}
}
